package org.diysearch.models;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.diysearch.interfaces.Model;

public class Page extends BaseModel {

	private int id;
	private String uri;
	private String title;
	private Date dateAdded;
	private Date dateLastModified;
	private int isPublished;
	private int doNotPublish;
	private int isPage;
	private String author;
	private String template;
	private List<PageElement> elements = new ArrayList<PageElement>();
	
	public Page() {}
	
	public String getTemplate() {
		return template;
	}

	public void setTemplate(String template) {
		this.template = template;
	}

	public List<PageElement> getElements() {
		return elements;
	}

	public void setElements(List<PageElement> elements) {
		this.elements = elements;
	}
	
	public PageElement getElementByName(String name) {
		PageElement element = null;
		if (elements != null || elements.size() > 0) {
			for (PageElement pe : elements) {
				if (pe.getKey().equals(name)) {
					element = pe;
				}
			}
		} 
		return element;
	}
	
	public void addPageElement (PageElement pe) {
		if (elements != null) {
			elements.add(pe);
		} else {
			elements = new ArrayList<PageElement>();
			elements.add(pe);
		}
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getUri() {
		return uri;
	}

	public void setUri(String uri) {
		this.uri = uri;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public Date getDateAdded() {
		return dateAdded;
	}

	public void setDateAdded(Date dateAdded) {
		this.dateAdded = dateAdded;
	}

	public Date getDateLastModified() {
		return dateLastModified;
	}

	public void setDateLastModified(Date dateLastModified) {
		this.dateLastModified = dateLastModified;
	}

	public int getIsPublished() {
		return isPublished;
	}

	public void setIsPublished(int isPublished) {
		this.isPublished = isPublished;
	}

	public int getDoNotPublish() {
		return doNotPublish;
	}

	public void setDoNotPublish(int doNotPublish) {
		this.doNotPublish = doNotPublish;
	}

	public int getIsPage() {
		return isPage;
	}

	public void setIsPage(int isPage) {
		this.isPage = isPage;
	}

	public String getAuthor() {
		return author;
	}

	public void setAuthor(String author) {
		this.author = author;
	}

	@Override
	public String getAliasName() {
		// TODO Auto-generated method stub
		return "page";
	}

}
